<!--
/**************************************************
* @ providerunbalancedetail.jsp
*
* Copyright   2006 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/05/19, Jenny Li
*  1) first release
/**************************************************
-->
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<html>
<head>
<title>对帐调整</title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/hi-check.js"></SCRIPT>
<%
	HashMap tMap = (HashMap)request.getAttribute("orderdept");
	ArrayList tOrderDeptList = (ArrayList)tMap.get("organization");
	ResultProcess tOrder = (ResultProcess)request.getAttribute("order");
	String isRequery  = (String)request.getAttribute("requery");
	ArrayList tList = new ArrayList();
%>
<script>

	function process(val){
		var category = "<%=request.getAttribute("deptCategory")%>";		
		if(val == 'Q'){
			var tStr = "";
			var tEnd = "";
			if(!isEmpty(unbalancedetailform.orderDeliverDateStr.value)){
				tStr = unbalancedetailform.orderDeliverDateStr.value.substr(0,4) + unbalancedetailform.orderDeliverDateStr.value.substr(5,2) + unbalancedetailform.orderDeliverDateStr.value.substr(8,2);

			}
			if(!isEmpty(unbalancedetailform.orderDeliverDateEnd.value)){
				tEnd = unbalancedetailform.orderDeliverDateEnd.value.substr(0,4) + unbalancedetailform.orderDeliverDateEnd.value.substr(5,2) + unbalancedetailform.orderDeliverDateEnd.value.substr(8,2);
			}
			if(parseInt(tStr) > parseInt(tEnd)){
					alert("订单创建周期的开始日期不能大于截止日期！");
					return false;
			}
			unbalancedetailform.action = "<%=response.encodeURL(root + "/A180212.do")%>";
    		unbalancedetailform.submit();			
		}else if(val == 'C'){
//			if(category != null && category == '1'){
//				unbalancedetailform.orderDeptId.value="0000";
//			}else if(category != null && category == '2'){
//				unbalancedetailform.providerName.value="";						
//			}
			unbalancedetailform.deliverGoodsId.value = "";
			unbalancedetailform.concentricityId.value = "";
			unbalancedetailform.manufInfo.value = "";
			unbalancedetailform.orderDeliverDateStr.value = "";
			unbalancedetailform.orderDeliverDateEnd.value = "";
			return false;		
		}else if(val=='NB'){
			if(pager.index != null){		
				if(!isCheckBoxselected(pager,pager.index)){
					alert("请至少选择一笔订单！");
					return false;			
				}else{
				    pager.deptId1.value="<%=request.getAttribute("deptId")%>";
				    pager.deptCategory1.value=category;				    
				    pager.balanceYM1.value="<%=request.getAttribute("balanceYM")%>";
				    //保存查询参数
					if(category != null && category == '1' ){
						pager.orderDeptId.value = unbalancedetailform.orderDeptId.value;
					}else if(category!= null && category == '2'){
						pager.providerName.value = unbalancedetailform.providerName.value;
					}				    	
				    pager.concentricityId.value = unbalancedetailform.concentricityId.value;
				    pager.manufInfo.value = unbalancedetailform.manufInfo.value;
				    pager.orderDeliverDateStr.value = unbalancedetailform.orderDeliverDateStr.value;
				    pager.orderDeliverDateEnd.value = unbalancedetailform.orderDeliverDateEnd.value;				    			    
					pager.action = "<%=response.encodeURL(root + "/A180213.do")%>";
					pager.submit();
				}
			}else{
				return false;
			}
		}else if(val == 'F'){
			if(document.pager.index != null){		
				if(!isCheckBoxselected(pager,pager.index)){
					alert("请至少选择一笔订单！");
					return false;			
				}else{
				    pager.deptId1.value="<%=request.getAttribute("deptId")%>";
				    pager.deptCategory1.value="<%=request.getAttribute("deptCategory")%>";				    
				    pager.balanceYM1.value="<%=request.getAttribute("balanceYM")%>";	
				    //保存查询参数
					if(category != null && category == '1' ){
						pager.orderDeptId.value = unbalancedetailform.orderDeptId.value;
					}else if(category!= null && category == '2'){
						pager.providerName.value = unbalancedetailform.providerName.value;
					}				    	
				    pager.concentricityId.value = unbalancedetailform.concentricityId.value;
				    pager.manufInfo.value = unbalancedetailform.manufInfo.value;
				    pager.orderDeliverDateStr.value = unbalancedetailform.orderDeliverDateStr.value;
				    pager.orderDeliverDateEnd.value = unbalancedetailform.orderDeliverDateEnd.value;				    			    
					pager.action = "<%=response.encodeURL(root + "/A180214.do")%>";
					pager.submit();
				}
			}else{
				return false;
			}
		}else if(val == 'M'){
		    var obj = new Array(11);
			if(document.pager.index != null){		
				if(!getCheckedLength(pager.index,true)){
					return false;			
				}else{
						if (pager.index.length > 1){
							for (i=0;i< pager.index.length;i++){
								if(pager.index[i].checked){
									obj[0] = pager.orderDetailIds[i].value;
									obj[1] = pager.orderIds[i].value;
									if(category != null && category == '1' ){
										obj[2] = unbalancedetailform.orderDeptId.value;	
									}else if(category!= null && category == '2'){
										obj[2] = unbalancedetailform.providerName.value;					
									}
									obj[3] = unbalancedetailform.concentricityId.value;
									obj[4] = unbalancedetailform.deliverGoodsId.value;
									obj[5] = unbalancedetailform.manufInfo.value;
									obj[6] = unbalancedetailform.orderDeliverDateStr.value;																				
									obj[7] = unbalancedetailform.orderDeliverDateEnd.value;
									obj[8] = category;	
									obj[9] = "<%=request.getAttribute("deptId")%>";	
									obj[10] = "<%=request.getAttribute("balanceYM")%>";						
								}							
							}
							
						}
						else {
							if(pager.index.checked){
								obj[0] = pager.orderDetailIds.value;
								obj[1] = pager.orderIds.value;	
								if(category != null && category == '1' ){
									obj[2] = unbalancedetailform.orderDeptId.value;	
								}else if(category!= null && category == '2'){
									obj[2] = unbalancedetailform.providerName.value;					
								}
								obj[3] = unbalancedetailform.concentricityId.value;
								obj[4] = unbalancedetailform.deliverGoodsId.value;
								obj[5] = unbalancedetailform.manufInfo.value;
								obj[6] = unbalancedetailform.orderDeliverDateStr.value;																				
								obj[7] = unbalancedetailform.orderDeliverDateEnd.value;													
								obj[8] = category;				
								obj[9] = "<%=request.getAttribute("deptId")%>";	
								obj[10] = "<%=request.getAttribute("balanceYM")%>";	
							}else{
								return false;
							}											
						}					
						if(confirm("是否确定调整？")){	
							openwin(obj);							
						}else{
							return false;
						}		
				}
			}			
		}else if(val == 'E'){
			unbalancedetailform.action = "<%=response.encodeURL(root + "/A180216.do")%>";
    		unbalancedetailform.submit();						
		}else if(val == 'CW'){
			window.opener.location.href = window.opener.location.href;
			//window.opener.location.reload();
			window.close();
		}	   
	}     
	function openwin(obj){
		var result = null;	
		result = showModalDialog("<%=response.encodeURL(root+"/A180210.do")%>?params=" + obj, window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:1200px;help:no;");
		if(result != null){
			unbalancemodifyform.curOrderId.value= result[0];
			unbalancemodifyform.curOrderDetailId.value=result[1];
			unbalancemodifyform.devGoodsOrderId.value=result[2];
			unbalancemodifyform.signer.value=result[3];
			unbalancemodifyform.signCount.value=result[4];
			unbalancemodifyform.signDate.value=result[5];
			unbalancemodifyform.goodsUnitprice.value=result[6];
			unbalancemodifyform.contactPerson.value=result[7];
			unbalancemodifyform.contactPhone.value=result[8];
			var category = result[9];
			//保存查询参数
			if(category == '1'){
				unbalancemodifyform.orderDeptId.value = unbalancedetailform.orderDeptId.value;
			}else if(category == '2'){
				unbalancemodifyform.providerName.value = unbalancedetailform.providerName.value;					
			}
			unbalancemodifyform.deliverGoodsId.value = unbalancedetailform.deliverGoodsId.value;
			unbalancemodifyform.concentricityId.value = unbalancedetailform.concentricityId.value;
			unbalancemodifyform.manufInfo.value = unbalancedetailform.manufInfo.value;
			unbalancemodifyform.orderDeliverDateStr.value = unbalancedetailform.orderDeliverDateStr.value;																				
			unbalancemodifyform.orderDeliverDateEnd.value = unbalancedetailform.orderDeliverDateEnd.value;
			unbalancemodifyform.deptCatgry.value = 	category;
			unbalancemodifyform.deptId.value = result[10];
			unbalancemodifyform.balanceYM.value = result[11];
			unbalancemodifyform.action = "<%=response.encodeURL(root+"/A180211.do")%>";
			unbalancemodifyform.submit();	
		}
	}	
	function control(val){
		if(val == 'requery'){
			<%
				if(isRequery != null && isRequery.equals("true")){
			%>
			unbalancedetailform.action = "<%=response.encodeURL(root + "/A180212.do")%>";
    		unbalancedetailform.submit();		
			<%		
				}
			%>
		}
	}	
		</script>
	</head>
	<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="control('requery')">
		<form name="unbalancedetailform" method="get">
		<input type="hidden" name="deptId" value="<%=request.getAttribute("deptId") %>">
		<input type="hidden" name="balanceYM" value="<%=request.getAttribute("balanceYM") %>">
		<input type="hidden" name="deptCategory" value="<%=request.getAttribute("deptCategory") %>">		
		
			<p><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><br>
			</p>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td height="20">
						<table width="100%" border="0" cellspacing="0" cellpadding="1">
							<tr height="20">
								<td height="30" width="758" class="mtxt_black">
								对帐调整
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="bg_line" height="2"></td>
				</tr>
			</table>
			<br>
			<table class="bg_table" id="Table1" cellspacing="1" cellpadding="0" style="PADDING-RIGHT:5px; PADDING-LEFT:5px"
				width="98%" align="center" border="0">
				<TR height="20">
				<%
					String tCategry = "";
					if(request.getAttribute("deptCategory")!=null){
					    tCategry = (String) request.getAttribute("deptCategory");
					}else{
						tCategry =(String) request.getParameter("deptCategory");
					}
					if(tCategry != null && tCategry.equals(GSBaseConstants.BALANCE_ORDERDEPT_TYPE)){
				%>
					<TD class="bg_column" align="center" width="15%">订货单位</TD>
					<TD class="bg_row_odd" colspan="3">
						<select name="orderDeptId" disabled>					
						<option value="0000">---全部---</option>
						<%
							String tOrderDept = request.getParameter("orderDeptId");
							String tConsoleDeptId = (String)request.getAttribute("deptId");
							if(tOrderDeptList != null && tOrderDeptList.size() > 0 ){	
							    if(tOrderDept != null && tOrderDept.equals("0000")){
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
						%>
										<option value="<%=temp[0]%>"><%=temp[1]%></option>						
						<%			    
									}
							    }else{
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
									    if(tConsoleDeptId != null && tConsoleDeptId.equals(temp[0])){
							%>
											<option value="<%=temp[0]%>" selected><%=temp[1]%></option>							
							<%
									    }else 
										if(tOrderDept != null && tOrderDept.equals(temp[0])){
							%>
											<option value="<%=temp[0]%>" selected>
											<%=temp[1]%></option>
							<%				    
										}else{
							%>
											<option value="<%=temp[0]%>"><%=temp[1]%></option>
							<%			
										}
									}
							    }
							}

						%>

						</select>
					</TD>
					<%
					}else if(tCategry != null && tCategry.equals(GSBaseConstants.BALANCE_PROVIDER_TYPE)){
					%>
					<TD class="bg_column" align="center" width="15%">供应商</TD>
					<TD class="bg_row_odd" align="left" colspan="3">
					<%
						String tColeProvider = (String)request.getAttribute("deptId");
						String tProvider = request.getParameter("providerName");
						String tColeProviderName = "";
						if(tColeProvider!=null){
							tColeProviderName = GSBaseManager.getProviderShortName(tColeProvider);
						}else if(tProvider != null){
							tColeProviderName = tProvider;
						}
					%>
					<input type="text" name="providerName" value="<%=tColeProviderName%>" maxlength="100" disabled>				
					</TD>					

					<%	
					}
					%>

				</TR>
				<TR height="20">
					<TD class="bg_column" align="center" width="15%">送货单号</TD>
					<TD align="left" class="bg_row_odd" width="35%">
						<INPUT type="text" ID="deliverGoodsId" NAME="deliverGoodsId" maxlength="20" value="<%=request.getParameter("deliverGoodsId")==null?"":request.getParameter("deliverGoodsId")%>">
					</TD>				
					<TD class="bg_column" align="center">集中编码</TD>
					<TD align="left" class="bg_row_odd">
					<input type="text" name="concentricityId" maxlength="20" value="<%=request.getParameter("concentricityId")==null?"":request.getParameter("concentricityId")%>">
					</TD>
				</TR>

				<tr>
					<TD class="bg_column" align="center">产品信息</TD>
					<TD class="bg_row_odd" colspan="3">
					<input type="text" name="manufInfo" maxlength="200" value="<%=request.getParameter("manufInfo")==null?"":request.getParameter("manufInfo")%>">（<FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商、附加属性等关键字的模糊查询</FONT>）&nbsp;
					</TD>
				</tr>
				<TR height="20">
					<TD class="bg_column" align="center">送货时间</TD>
					<TD align="left" class="bg_row_odd" colspan="3">
					<input type="text"	name="orderDeliverDateStr" value="<%=request.getParameter("orderDeliverDateStr")==null?"":request.getParameter("orderDeliverDateStr")%>" length="20" onfocus="setday(this)" readonly> 
					～<input type="text"	name="orderDeliverDateEnd" length="20" value="<%=request.getParameter("orderDeliverDateEnd")==null?"":request.getParameter("orderDeliverDateEnd")%>" onfocus="setday(this)" readonly>
					</TD>
				</TR>
			</table>
            <%if(tOrder != null){
                int totalRecords = 0;
                if(request.getAttribute("totalRecords")!=null){
                    totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                }
                int defaultPageSize =10;
                if(request.getAttribute("pageSize")!=null){
                    defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                }
            tList = tOrder.getAllRecoreds();
            %>
            <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'></page:pager>
            <%} %>
		</form>
		<p align="center">
		<input type="button" name="查询" value="查询" class="kuang" onclick="process('Q')"/>&nbsp;
		<input type="button" name="清空" value="清空" class="kuang" onclick="process('C')"/>&nbsp;
		</p>
		<center>
		<%
			if(tOrder != null){
		%>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td>
            <form name='pager' method="post">	
							<table class="bg_table" id="tableId" cellspacing="1" cellpadding="2" width="100%" align="center"
								border="0">
								<input type="hidden" name="deptId1">
								<input type="hidden" name="balanceYM1">								
								<input type="hidden" name="deptCategory1">								
								<input type="hidden" name="orderDeptId">
								<input type="hidden" name="providerName">
								<input type="hidden" name="deliverGoodsId">																
								<input type="hidden" name="concentricityId">																
								<input type="hidden" name="manufInfo">																																
								<input type="hidden" name="orderDeliverDateStr">	
								<input type="hidden" name="orderDeliverDateEnd">																	
								<tbody>
									<tr class="bg_column" height="20">
										<td class="top" align="center" colspan="17">
											<b>订单信息列表</b>
										</td>
									</tr>
									<%
										if(tList != null && tList.size() > 0){
									%>
									<tr class="bg_column" height="20">
								    <td width="960" height="16" colspan="17" align="right">
											<!--导航条-->
								    		<page:navigator type='text'  queryForm="unbalancedetailform"/>
								    </td>									
								    </tr>
								    <%} %>
									<tr class="bg_column" height="20">
										<td class="top" align="center">
											<div align="center" class="txt_content">送货单号</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">订货单位</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">供应商</div>
										</td>										
										<td class="top" align="center">
											<div align="center" class="txt_content">集中编码</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">产品名称</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">是否交易平台产品</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">规格</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">型号</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">品牌</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">生产厂商</div>
										</td>

										<td class="top" align="center">
											<div align="center" class="txt_content">订货数量</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">设定价格<br>
												（元）</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">签收数量</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">签收价格<br>
												（元）</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">签收日期<br>
												</div>
										</td>										
										<td class="top" align="center">
											<div align="center" class="txt_content">详细</div>
										</td>
									</tr>
									<%
										if(tList != null && tList.size() > 0){
										    for(int i=0; i<tList.size(); i++){
										        String[] tStr = (String[])tList.get(i);
												String tTempStr="";
												if(i%2==0){
													tTempStr="bg_row_odd";
												}else {
													tTempStr="bg_row_even";
												}										        
									%>
									<tr class="<%=tTempStr%>" height="20">
											<input type="hidden" name="orderDetailIds" value="<%=tStr[1]%>">									
											<input type="hidden" name="orderIds" value="<%=tStr[0]%>">																				
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[2] %></div><!-- 出货单号-->
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[3] %></div><!-- 订货单位 -->
										</td>
										<td class="top" align="center">
										<%
										String temp = "";
										if(tStr[8].equals("0")&& tStr[9].equals("0")){
											temp = "(采购网配送)";
										}											
										%>
											<div align="center" class="txt_content"><a href="<%=response.encodeURL(root + "/A400108.do?providerId=" + tStr[4]) %>" target="_blank"><%=tStr[5] %></a><%=temp%></div><!-- 供应商 -->
										</td>										
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[6] %></div><!-- 集中编码 -->
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">
											<A href="<%=response.encodeURL(root + "/A150103.do?&concentricityId=" + tStr[6])%>" target="_blank"><%=tStr[7]%></A><!-- 产品名称 -->
											</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=GSBaseManager.getIsTradeManuf(tStr[8])%></div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[10]%></div><!-- 规格 -->
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[11]%></div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[12]%></div>
										</td>
										<td class="top" align="center">

											<div align="center" class="txt_content"><%=tStr[13]%></div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[14]+tStr[15] %></div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content"><%=tStr[16]%></div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">
												<%=tStr[17] %>
											</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">
												<%=tStr[18] %>
											</div>
										</td>
										<td class="top" align="center">
											<div align="center" class="txt_content">
												<%=tStr[19]%>
											</div>
										</td>										
										<td class="top" align="center">
											<div align="center" class="txt_content">
											<a href="<%=response.encodeURL(root+"/A150505.do")%>?orderId=<%=tStr[0]%>&orderDetailId=<%=tStr[1]%>" target="_blank">详细</A></div>
										</td>
									</tr>
									<%
										    }
									%>
									<tr class="bg_column" height="20">
								    <td width="960" height="16" colspan="17" align="right">
											<!--导航条-->
								    		<page:navigator type='text' queryForm="unbalancedetailform"/>
								    </td>
								    </tr>
							    <%
									}else{
								%>
										<font color="red">没有符合条件的订单信息</font>
								<%
									}
								%>
								    
								</tbody>
							</table>
				</form>						
					</td>
				</tr>
			</table>
		</center>
			<p align="center">
				<tr>
					<td align="center">
						<INPUT type="button" value="导出至Excel" class="kuang" onClick="process('E')">	
						<INPUT type="button" value="关闭" class="kuang" onClick="process('CW')">												
						<br>
					</td>
				</tr>
				</p>			
			<%
				}
				if(tOrder == null && isRequery != null && isRequery.equals("true")){
		    %>
		    	<font size="2">数据查询中......</font>
		    <%
		    	}
		    %>				
	<form name="unbalancemodifyform" method="post">
		<input type="hidden" name="curOrderId" >
		<input type="hidden" name="curOrderDetailId" >
		<input type="hidden" name="devGoodsOrderId" >
		<input type="hidden" name="signer" >
		<input type="hidden" name="signCount" >
		<input type="hidden" name="signDate" >
		<input type="hidden" name="goodsUnitprice" >						
		<input type="hidden" name="contactPerson" >
		<input type="hidden" name="contactPhone" >		
	    <input type="hidden" name="orderDetailId">
	    <input type="hidden" name="providerName">
	    <input type="hidden" name="orderDeptId">            
	    <input type="hidden" name="concentricityId"> 
	    <input type="hidden" name="manufInfo"> 
	    <input type="hidden" name="orderDeliverDateStr"> 
	    <input type="hidden" name="orderDeliverDateEnd">  		
	    <input type="hidden" name="orderDetailStatus">     
	    <input type="hidden" name="deliverGoodsId">	
	    <input type="hidden" name="deptCatgry">		    
	    <input type="hidden" name="deptId">		    	    
	    <input type="hidden" name="balanceYM">		    	    
	</form>		    		
	</body>
</html>